package domain

import "errors"

// Address 值对象
type Address struct {
	street, city, state, country string
}

// NewAddress 创建一个新的 Address 值对象
func NewAddress(street, city, state, country string) (*Address, error) {
	if street == "" || city == "" || state == "" || country == "" {
		return nil, errors.New("all fields must be filled in")
	}
	return &Address{street, city, state, country}, nil
}

// GetValue 获取 Address 的完整地址字符串
func (a *Address) GetValue() string {
	return a.street + ", " + a.city + ", " + a.state + ", " + a.country
}

// Equal 判断两个 Address 值对象是否相等
func (a *Address) Equal(other *Address) bool {
	return a.street == other.street &&
		a.city == other.city &&
		a.state == other.state &&
		a.country == other.country
}
